package cn.tedu.luban.worker.main.repository;

import cn.tedu.luban.worker.main.converter.WorkerAuditConverter;
import cn.tedu.luban.worker.main.mapper.WorkerAuditLogMapper;
import cn.tedu.luban.worker.protocol.bo.AdminAuditBO;
import cn.tedu.luban.worker.protocol.dos.WorkerAuditLogDO;
import cn.tedu.luban.worker.protocol.param.AuditSubmitParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Slf4j
public class WorkerAuditLogRepoImpl implements WorkerAuditLogRepository {

    @Autowired(required = false)
    private WorkerAuditLogMapper workerAuditLogMapper;

    @Autowired
    private WorkerAuditConverter workerAuditConverter;

    @Override
    public List<AdminAuditBO> findAuditLogs(Long userId) {
        List<WorkerAuditLogDO> dos = workerAuditLogMapper.selectWorkerAuditLogs(userId);
        return workerAuditConverter.dos2bos(dos);
    }

    @Override
    public Long save(AuditSubmitParam param) {

        WorkerAuditLogDO logDO = workerAuditConverter.param2do(param);
        workerAuditLogMapper.insert(logDO);

        return logDO.getId();
    }
}












